home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / checkt1g / chatnet.frm next >
Text File  |  1999-08-26  |  13KB  |  413 lines

  1. VERSION 5.00
  2. Object = "{FFACF7F3-B868-11CE-84A8-08005A9B23BD}#1.7#0"; "DSSOCK32.OCX"
  3. Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
  4. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  5. Begin VB.Form chatnet 
  6.    BorderStyle     =   1  'Fixed Single
  7.    Caption         =   " chat net"
  8.    ClientHeight    =   4425
  9.    ClientLeft      =   45
  10.    ClientTop       =   330
  11.    ClientWidth     =   7485
  12.    Icon            =   "chatnet.frx":0000
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   4425
  17.    ScaleWidth      =   7485
  18.    StartUpPosition =   3  'Windows Default
  19.    Begin VB.TextBox Text6 
  20.       Height          =   285
  21.       Left            =   6240
  22.       TabIndex        =   13
  23.       Top             =   20400
  24.       Width           =   255
  25.    End
  26.    Begin VB.TextBox Text5 
  27.       Height          =   285
  28.       Left            =   6000
  29.       TabIndex        =   12
  30.       Top             =   20400
  31.       Width           =   375
  32.    End
  33.    Begin MSComctlLib.StatusBar stats 
  34.       Align           =   2  'Align Bottom
  35.       Height          =   255
  36.       Left            =   0
  37.       TabIndex        =   11
  38.       Top             =   4170
  39.       Width           =   7485
  40.       _ExtentX        =   13203
  41.       _ExtentY        =   450
  42.       _Version        =   393216
  43.       BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
  44.          NumPanels       =   1
  45.          BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  46.             Object.Width           =   7056
  47.             MinWidth        =   7056
  48.             Text            =   "multi user chat example  by  Jon Cromer"
  49.             TextSave        =   "multi user chat example  by  Jon Cromer"
  50.          EndProperty
  51.       EndProperty
  52.    End
  53.    Begin VB.CommandButton Command1 
  54.       Caption         =   "Connect"
  55.       Height          =   315
  56.       Left            =   5880
  57.       TabIndex        =   10
  58.       Top             =   3480
  59.       Width           =   1335
  60.    End
  61.    Begin VB.TextBox Text3 
  62.       Height          =   285
  63.       Left            =   5640
  64.       TabIndex        =   9
  65.       Top             =   3000
  66.       Width           =   1815
  67.    End
  68.    Begin VB.TextBox Text4 
  69.       Height          =   285
  70.       Left            =   5640
  71.       TabIndex        =   7
  72.       Text            =   "127.0.0.1"
  73.       Top             =   2400
  74.       Width           =   1815
  75.    End
  76.    Begin VB.Timer Timer1 
  77.       Interval        =   1
  78.       Left            =   5640
  79.       Top             =   3840
  80.    End
  81.    Begin VB.ListBox List1 
  82.       Height          =   1650
  83.       Left            =   5640
  84.       TabIndex        =   5
  85.       Top             =   240
  86.       Width           =   1815
  87.    End
  88.    Begin VB.TextBox Text2 
  89.       BeginProperty Font 
  90.          Name            =   "Arial"
  91.          Size            =   9
  92.          Charset         =   0
  93.          Weight          =   400
  94.          Underline       =   0   'False
  95.          Italic          =   0   'False
  96.          Strikethrough   =   0   'False
  97.       EndProperty
  98.       Height          =   285
  99.       Left            =   0
  100.       TabIndex        =   2
  101.       Top             =   3840
  102.       Width           =   5535
  103.    End
  104.    Begin RichTextLib.RichTextBox Text1 
  105.       Height          =   3735
  106.       Left            =   0
  107.       TabIndex        =   1
  108.       Top             =   0
  109.       Width           =   5535
  110.       _ExtentX        =   9763
  111.       _ExtentY        =   6588
  112.       _Version        =   327680
  113.       ScrollBars      =   2
  114.       TextRTF         =   $"chatnet.frx":0442
  115.    End
  116.    Begin dsSocketLib.dsSocket dsSocket1 
  117.       Height          =   420
  118.       Left            =   6240
  119.       TabIndex        =   0
  120.       Top             =   3840
  121.       Width           =   420
  122.       _Version        =   65543
  123.       _ExtentX        =   741
  124.       _ExtentY        =   741
  125.       _StockProps     =   64
  126.       LocalPort       =   2000
  127.       RemoteHost      =   ""
  128.       RemotePort      =   2000
  129.       ServiceName     =   ""
  130.       RemoteDotAddr   =   ""
  131.       Linger          =   -1  'True
  132.       Timeout         =   10
  133.       LineMode        =   0   'False
  134.       EOLChar         =   10
  135.       BindConnect     =   0   'False
  136.       SocketType      =   0
  137.    End
  138.    Begin VB.Label Label4 
  139.       BackStyle       =   0  'Transparent
  140.       Caption         =   "Nick Name:"
  141.       Height          =   255
  142.       Left            =   5640
  143.       TabIndex        =   8
  144.       Top             =   2760
  145.       Width           =   975
  146.    End
  147.    Begin VB.Label Label3 
  148.       BackStyle       =   0  'Transparent
  149.       Caption         =   "Server Address:"
  150.       Height          =   255
  151.       Left            =   5640
  152.       TabIndex        =   6
  153.       Top             =   2160
  154.       Width           =   1215
  155.    End
  156.    Begin VB.Label Label2 
  157.       BackStyle       =   0  'Transparent
  158.       Caption         =   "0"
  159.       BeginProperty Font 
  160.          Name            =   "MS Sans Serif"
  161.          Size            =   8.25
  162.          Charset         =   0
  163.          Weight          =   700
  164.          Underline       =   0   'False
  165.          Italic          =   0   'False
  166.          Strikethrough   =   0   'False
  167.       EndProperty
  168.       Height          =   255
  169.       Left            =   6240
  170.       TabIndex        =   4
  171.       Top             =   0
  172.       Width           =   1215
  173.    End
  174.    Begin VB.Label Label1 
  175.       BackStyle       =   0  'Transparent
  176.       Caption         =   "Users:"
  177.       Height          =   255
  178.       Left            =   5640
  179.       TabIndex        =   3
  180.       Top             =   0
  181.       Width           =   855
  182.    End
  183. End
  184. Attribute VB_Name = "chatnet"
  185. Attribute VB_GlobalNameSpace = False
  186. Attribute VB_Creatable = False
  187. Attribute VB_PredeclaredId = True
  188. Attribute VB_Exposed = False
  189. 'hello.  this is a quick example i wrote for a multi
  190. 'user chat.  this example was written in under 30
  191. 'minutes so theres no use for just "recycling" my form
  192. 'because its so easy to do on your own.  please please
  193. 'please dont just rename this form and change the
  194. 'caption and call it yours.  thats lame and you wont
  195. 'learn anything about programming.  this example was
  196. 'meant to be used as a learning tool.  i hope you like
  197. 'it and it helps you out in understanding network
  198. 'programming and just general programming a bit better.
  199. '            - Jon Cromer
  200. '  email:  senate@popmail.com
  201. '  AIM:  senate heh, DontTrustHAL9000
  202. '
  203.  
  204. Private Sub Command1_Click()
  205. On Error Resume Next  'this is a statement you should
  206.                       'be starting most of your coding
  207.                       'with.
  208.  
  209.  
  210. 'we'll be using one command button for connecting and
  211. 'disconnecting because i was too lazy to think of how
  212. 'to design this with enough space without using TAB's
  213. '(which i use in almost every program i do)
  214. If Command1.Caption = "Connect" Then
  215.  'checks if we can connect
  216.  If dsSocket1.LocalDotAddr = "0.0.0.0" Then
  217.  stats.Panels.Item(1).text = "Connection Error:  No internet connection detected"
  218.  'display the error.
  219.  MsgBox "You don't seem to be connected to an Internet Service Provider currently or you have not been assigned a valid IP Address." & vbCrLf & "No connection will be made.", vbInformation, "Error"
  220.  'this is if the person isn't on the internet.
  221.  'if they aint, they cant chat.
  222.  Exit Sub
  223.  End If
  224.  
  225. dsSocket1.RemotePort = 2000  'set the remote port
  226. dsSocket1.RemoteDotAddr = Text4 'set the server address
  227. dsSocket1.Connect  'connect to the server.
  228. stats.Panels.Item(1).text = "Connected to " & Text4
  229. 'display the connection status.
  230. Text3.Enabled = False
  231. Text4.Enabled = False
  232. 'disable the server address and nick name box so they
  233. 'cant be changed durring chatting.
  234. Command1.Caption = "Disconnect"
  235. 'set the buttons caption to disconnect so we know we're
  236. 'connected to the server
  237. Exit Sub
  238. End If
  239.  
  240. If Command1.Caption = "Disconnect" Then
  241. dsSocket1.Send = "_$l:" & Text3
  242. 'send the command that you are leaving the chat.
  243. dsSocket1.Close   'close the connection
  244.